package structs

import (
	"github.com/shopspring/decimal"
	"time"
)

type CmcStatus struct {
	Timestamp 			string 		`json:"timestamp"`
	ErrorCode 			int 		`json:"error_code"`
	ErrorMessage 		string 		`json:"error_message"`
	Elapsed 			int 		`json:"elapsed"`
	CreditCount 		int 		`json:"credit_count"`
}

// ---------------------
// Coin

type CmcCoinIdMap struct {
	Id				int			`json:"id" redis:"id"`
	Name 			string 		`json:"name" redis:"name"`
	Slug 			string 		`json:"slug" redis:"slug"`
	Symbol 			string 		`json:"symbol" redis:"symbol"`
	IsActive 		uint8 		`json:"is_active" redis:"is_active"`
	FirstHistory	time.Time	`json:"first_historical_data" redis:"first_historical_data"`
	LastHistory 	time.Time 	`json:"last_historical_data" redis:"last_historical_data"`
}

type CmcCoinMetaData struct {
	Id 				int 			`json:"id" redis:"id"`
	Name 			string 			`json:"name" redis:"name"`
	Symbol 			string 			`json:"symbol" redis:"symbol"`
	Category 		string 			`json:"category" redis:"category"`
	Slug 			string 			`json:"slug" redis:"slug"`
	Logo 			string 			`json:"logo" redis:"logo"`
	Tags 			[]string 		`json:"tags" redis:"tags"`
	Urls 			struct{
		Website 		[]string 		`json:"website" redis:"website"`
		Explorer 		[]string 		`json:"explorer" redis:"explorer"`
		SourceCode 		[]string 		`json:"source_code" redis:"source_code"`
		MessageBoard	[]string		`json:"message_board" redis:"message_board"`
		Chat 			[]string 		`json:"chat" redis:"chat"`
		Announcement 	[]string 		`json:"announcement" redis:"announcement"`
		Reddit 			[]string 		`json:"reddit" redis:"reddit"`
		Twitter 		[]string 		`json:"twitter" redis:"twitter"`
	}		`json:"urls" redis:"urls"`
}

type Quote struct {
	Price			float64		`json:"price" redis:"price"`
	Volume24h		float64 	`json:"volume_24h" redis:"volume_24h"`
	Percent1h 		float64 	`json:"percent_change_1h" redis:"percent_change_1h"`
	Percent24h 		float64 	`json:"percent_change_24h" redis:"percent_change_24h"`
	Percent7d 		float64 	`json:"percent_change_7d" redis:"percent_change_7d"`
	MarketCap 		float64 	`json:"market_cap" redis:"market_cap"`
	LatestUpdated 	string 		`json:"latest_updated" redis:"last_updated"`
}


type MarketCoinBase struct {
	Id					int 					`json:"id" redis:"id"`
	Name 				string 					`json:"name" redis:"name"`
	Symbol 				string 					`json:"symbol" redis:"symbol"`
	Slug 				string 					`json:"slug" redis:"slug"`
	CirculatingSupply 	float64 				`json:"circulating_supply" redis:"circulating_supply"`
	TotalSupply 		float64 				`json:"total_supply" redis:"total_supply"`
	MaxSupply 			float64 				`json:"max_supply" redis:"max_supply"`
	DateAdded 			string 					`json:"date_added" redis:"date_added"`
	NumMarketPairs 		int 					`json:"num_market_pairs" redis:"num_market_pairs"`
	CmcRank 			int 					`json:"cmc_rank" redis:"cmc_rank"`
	LastUpdated 		string 					`json:"last_updated" redis:"last_updated"`
}

type MarketQuote struct {
	MarketCoinBase
	Quotes 				map[string]Quote 		`json:"quote" redis:"quote"`
}

// -----------------------
// Exchanges

type CmcMarketPairInfo struct {
	CurrencyId 			int 			`json:"currency_id" redis:"currency_id"`
	CurrencySymbol 		string 			`json:"currency_symbol" redis:"currency_symbol"`
	CurrencyType	 	string 			`json:"currency_type" redis:"currency_type"`
}

type CmcMarketPairQuote struct {
	Price 				decimal.Decimal  	`json:"price" redis:"price"`
	Volume24h 			decimal.Decimal 	`json:"volume_24h" redis:"volume_24h"`
	Volume24hBase 	decimal.Decimal 		`json:"volume_24h_base" redis:"volume_24h_base"`
	Volume24hQuote 	decimal.Decimal 		`json:"volume_24h_quote" redis:"volume_24h_quote"`
	LastUpdated 		time.Time 			`json:"last_updated" redis:"last_updated"`
}

// 获取交易所交易对信息
type CmcExchangeMarketPairs struct {
	Id 					int 			`json:"id" redis:"id"`
	Name 				string 			`json:"name" redis:"name"`
	Slug 				string 			`json:"slug" redis:"slug"`
	NumMarketPairs 		int 			`json:"num_market_pairs" redis:"number_market_pairs"`
	MarketPairs 		[]struct{
		MarketPair 			string 				`json:"market_pair" redis:"market_pair"`
		MarketPairBase 		CmcMarketPairInfo	`json:"market_pair_base" redis:"market_pair_base"`
		MarketPairQuote 	CmcMarketPairInfo 	`json:"market_pair_quote" redis:"market_pair_quote"`
		Quote 				map[string]CmcMarketPairQuote	`json:"quote" redis:"quote"`
	}									`json:"market_pairs" redis:"market_pairs"`
}

type CmcExchangeMetaData struct {
	Id 					int 					`json:"id" redis:"id"`
	Urls 			struct{
		WebSite 			[]string			`json:"website" redis:"website"`
		Twitter 			[]string			`json:"twitter" redis:"twitter"`
		Blog 				[]string 			`json:"blog" redis:"blog"`
		Chat 				[]string 			`json:"chat" redis:"chat"`
		Fee 				[]string 			`json:"fee" redis:"fee"`
	}											`json:"urls" redis:"urls"`
	Logo 				string 					`json:"logo" redis:"logo"`
	Name 				string 					`json:"name" redis:"name"`
	Slug 				string 					`json:"slug" redis:"slug"`
}

type CmcExchangeIdMap struct {
	Id				int			`json:"id" redis:"id"`
	Name 			string 		`json:"name" redis:"name"`
	Slug 			string 		`json:"slug" redis:"slug"`
	IsActive 		uint8 		`json:"is_active" redis:"is_active"`
	FirstHistory	time.Time	`json:"first_historical_data" redis:"first_historical_data"`
	LastHistory 	time.Time 	`json:"last_historical_data" redis:"last_historical_data"`
}

type ExchangeQuote struct {
	Volume24h 		decimal.Decimal 		`json:"volume_24h" redis:"volume_24h"`
	LastUpdated 	string 					`json:"last_updated" redis:"last_updated"`
}

type ExchangeLatestData struct {
	Id				int 				`json:"id" redis:"id"`
	Name 			string 				`json:"name" redis:"name"`
	Slug 			string 				`json:"slug" redis:"slug"`
	NumMarketPairs	int 				`json:"num_market_pairs" redis:"num_market_pairs"`
	LastUpdated 	string 				`json:"last_updated" redis:"last_updated"`
	Quotes 			map[string]ExchangeQuote 	`json:"quote" redis:"quote"`
}

